package cn.mastercom.common.util;

import java.util.*;

public class ArraysUtil {
    private ArraysUtil() {
        throw new IllegalStateException("Utility class");
    }

    /**
     * 求量数组的交集
     */
    public static String[] intersect(String[] arr1, String[] arr2) {
        List<String> l = new LinkedList<>();
        Set<String> common = new HashSet<>();
        for(String str:arr1){
            if(!l.contains(str)){
                l.add(str);
            }
        }
        for(String str:arr2){
            if(l.contains(str)){
                common.add(str);
            }
        }
        String[] result = {};
        return common.toArray(result);
    }

}
